<template>
    <view class="ddinfo">
        <view class="formbd">
            <navigator class="flex-row flex-y-center sjname" openType="redirect" :url="'../seller/index?sjid=' + odinfo.store.id">
                <view class="ddxh" :style="'color:' + color">#{{ odinfo.order.id }}</view>
                <view class="flex-grow-1" style="color: #999; font-size: 22rpx; font-weight: normal">订单编号：{{ odinfo.order.order_num }}</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '2'">等待商家接单</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '3' && odinfo.order.order_type == '1'">等待送达</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '3' && odinfo.order.order_type == '2'">等待客户自提</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '4' || odinfo.order.state == '5'">订单已完成</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '6'">订单已取消</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '7'">商家拒绝接单</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '8'">客户申请退款</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '9'">商家已退款</view>
                <view class="flex-grow-0 flex-y-center" :style="'color:' + color" v-if="odinfo.order.state == '10'">商家拒绝退款</view>
            </navigator>
            <view class="cart-item flex-row flex-y-center" v-for="(item, index) in odinfo.good" :key="index">
                <view class="xzhiding" v-if="item.is_jc == '1'">加菜</view>

                <view class="flex-grow-0 flex-y-center">
                    <image class="goods-pic" mode="aspectFill" :src="item.img"></image>
                </view>

                <view class="flex-grow-1 flex-col">
                    <view class="flex-grow-1">
                        <view class="goods-name">{{ item.name }}</view>
                        <view class="attr-list">
                            <view class="attr-item">{{ item.spec }}</view>
                        </view>
                    </view>
                    <view class="flex-grow-0 flex-row">
                        <view class="flex-grow-1 num">×{{ item.number }}</view>
                        <view class="flex-grow-0 price">￥{{ item.money }}</view>
                    </view>
                </view>
            </view>
            <block v-if="odinfo.order.type == '1'">
                <view class="formbdyh flex-row flex-y-center">
                    <view class="flex-row flex-y-center flex-grow-1">
                        <view class="yhhead bao">包</view>
                        <view v-if="odinfo.storeset.box_name != ''">{{ odinfo.storeset.box_name }}</view>
                        <view v-else>包装费</view>
                    </view>
                    <view class="flex-grow-0">￥{{ odinfo.order.box_money }}</view>
                </view>
                <view class="formbdyh flex-row flex-y-center">
                    <view class="flex-row flex-y-center flex-grow-1">
                        <view class="yhhead pei">配</view>
                        <view>配送费</view>
                    </view>
                    <view class="flex-grow-0" v-if="odinfo.order.order_type == '1'">￥{{ odinfo.order.ps_money }}</view>
                    <view class="flex-grow-0" style="color: #999" v-if="odinfo.order.order_type == '2'">到店用餐无配送费</view>
                </view>
            </block>
            <view class="formftyh">
                <view class="formbdyh flex-row flex-y-center">
                    <view class="flex-row flex-y-center flex-grow-1">
                        <view class="yhhead jian">减</view>
                        <view>在线支付满减</view>
                    </view>
                    <view class="flex-grow-0">-￥{{ odinfo.order.mj_money }}</view>
                </view>
                <view class="formbdyh flex-row flex-y-center" v-if="odinfo.order.xyh_money != '0.00'">
                    <view class="flex-row flex-y-center flex-grow-1">
                        <view class="yhhead xin">新</view>
                        <view>新客户下单立减</view>
                    </view>
                    <view class="flex-grow-0">-￥{{ odinfo.order.xyh_money }}</view>
                </view>
                <view class="weui-cells weui-cells_after-title" style="border-top: 1rpx solid #f4f4f4; font-size: 11pt" v-if="odinfo.order.yhq_money != '0.00'">
                    <navigator class="weui-cell weui-cell_access" hoverClass="weui-cell_active">
                        <view class="weui-cell__hd">
                            <image
                                mode="aspectFit"
                                src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/youhuiquan.png"
                                style="margin-right: 15rpx; vertical-align: middle; width: 40rpx; height: 40rpx"
                            ></image>
                        </view>
                        <view class="weui-cell__bd">商家优惠券</view>
                        <view class="">-￥{{ odinfo.order.yhq_money }}</view>
                    </navigator>
                </view>
                <view class="weui-cells weui-cells_after-title" style="border-top: 1rpx solid #f4f4f4; font-size: 11pt" v-if="odinfo.order.yhq_money2 != '0.00'">
                    <navigator class="weui-cell weui-cell_access" hoverClass="weui-cell_active">
                        <view class="weui-cell__hd">
                            <image mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/hb.png" style="margin-right: 15rpx; vertical-align: middle; width: 40rpx; height: 40rpx"></image>
                        </view>
                        <view class="weui-cell__bd">红包</view>
                        <view class="">-￥{{ odinfo.order.yhq_money2 }}</view>
                    </navigator>
                </view>
                <view class="sfk flex-row flex-y-center">
                    <view class="sfk-fv flex-grow-0">实付款</view>
                    <view class="flex-grow-1 xiaoji">
                        <view>已优惠￥{{ odinfo.order.discount }}</view>
                        <view style="color: #999; font-size: 26rpx; font-weight: normal">小计</view>
                        <view style="color: #999; font-size: 26rpx; font-weight: normal">￥{{ odinfo.order.money }}</view>
                    </view>
                </view>
                <view class="sfk flex-row flex-y-center">
                    <view class="sfk-fv flex-grow-0" style="color: #e80000">预计收入</view>
                    <view class="flex-grow-1 xiaoji">
                        <view></view>
                        <view></view>
                        <view>￥{{ odinfo.order.yj_money }}</view>
                    </view>
                </view>
            </view>
            <view class="formft">
                <view class="weui-cells weui-cells_after-title">
                    <view class="weui-cell weui-cell_access" hoverClass="weui-cell_active" v-if="odinfo.storeset.is_cj == '1'">
                        <view class="weui-cell__bd">{{ odinfo.storeset.cj_name }}</view>
                        <view class="weui-cell__ft">{{ odinfo.order.tableware }}份</view>
                    </view>
                    <view class="weui-cell weui-cell_access" hoverClass="weui-cell_active" v-if="odinfo.order.note != ''">
                        <view class="weui-cell__bd" style="min-width: 120rpx">备注</view>
                        <view class="weui-cell__ft">{{ odinfo.order.note }}</view>
                    </view>
                    <view @tap="maketel" class="weui-cell weui-cell_access" :data-tel="odinfo.order.tel">
                        <view class="weui-cell__hd">
                            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/lxsj.png" style="margin-right: 5px; vertical-align: middle; width: 30rpx; height: 30rpx"></image>
                        </view>
                        <view class="weui-cell__bd lxsj">联系客户</view>
                        <view
                            @tap.stop.prevent="location"
                            class="weui-cell__ft weui-cell__ft_in-access lxsj"
                            :data-address="odinfo.order.address"
                            :data-lat="odinfo.order.lat"
                            :data-lng="odinfo.order.lng"
                            v-if="odinfo.order.order_type == '1'"
                        >
                            查看收货地址
                        </view>
                    </view>
                </view>
            </view>
            <view class="formft" v-if="odinfo.order.type == '1'">
                <view class="weui-cells__title headtitle">配送信息</view>
                <view class="weui-cells weui-cells_after-title">
                    <view class="weui-cell" v-if="odinfo.order.order_type == '1'">
                        <view class="weui-cell__bd">配送时间</view>
                        <view class="weui-cell__ft">{{ odinfo.order.delivery_time }}</view>
                    </view>
                    <view class="weui-cell" v-if="odinfo.order.order_type == '2'">
                        <view class="weui-cell__bd">买家自提</view>
                        <view class="weui-cell__ft">自提时间：{{ odinfo.order.delivery_time }}</view>
                    </view>
                    <view class="weui-cell" v-if="odinfo.order.order_type == '1'">
                        <view class="weui-cell__bd">收货地址</view>
                        <view class="weui-cell__ft">{{ odinfo.order.address }}</view>
                    </view>
                    <view class="weui-cell">
                        <view class="weui-cell__bd">联系方式</view>
                        <view class="weui-cell__ft">
                            {{ odinfo.order.name }}
                            <text v-if="odinfo.order.sex == '1'">(先生)</text>
                            <text v-if="odinfo.order.sex == '2'">(女士)</text>
                            {{ odinfo.order.tel }}
                        </view>
                    </view>
                    <view class="weui-cell" v-if="odinfo.order.order_type == '1'">
                        <view class="weui-cell__bd">配送方式</view>
                        <view class="weui-cell__ft">{{ odinfo.storeset.ps_mode }}</view>
                    </view>
                </view>
            </view>
            <view class="formft">
                <view class="weui-cells__title headtitle">订单信息</view>
                <view class="weui-cells weui-cells_after-title">
                    <view class="weui-cell">
                        <view class="weui-cell__bd">订单号</view>
                        <view class="weui-cell__ft">
                            {{ odinfo.order.order_num }}
                            <text @tap="copyText" class="copy" :data-text="odinfo.order.order_num">复制</text>
                        </view>
                    </view>
                    <view class="weui-cell">
                        <view class="weui-cell__bd">支付方式</view>
                        <view class="weui-cell__ft" v-if="odinfo.order.pay_type == '1'">微信支付</view>
                        <view class="weui-cell__ft" v-if="odinfo.order.pay_type == '2'">余额支付</view>
                        <view class="weui-cell__ft" v-if="odinfo.order.pay_type == '4'">货到付款</view>
                        <view class="weui-cell__ft" v-if="odinfo.order.pay_type == '5'">餐后支付</view>
                    </view>
                    <view class="weui-cell">
                        <view class="weui-cell__bd">下单时间</view>
                        <view class="weui-cell__ft">{{ odinfo.order.time }}</view>
                    </view>
                </view>
            </view>
            <view class="formft"></view>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var qqmapsdk;
var app = getApp();
var util = require('../../../utils/util.js');
var QQMapWX = require('../../../utils/qqmap-wx-jssdk.js');
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            color: '#34aaff',

            odinfo: {
                store: {
                    id: ''
                },

                order: {
                    id: '',
                    order_num: '',
                    state: '',
                    order_type: '',
                    type: '',
                    box_money: '',
                    ps_money: '',
                    mj_money: '',
                    xyh_money: '',
                    yhq_money: '',
                    yhq_money2: '',
                    discount: '',
                    money: '',
                    yj_money: '',
                    tableware: '',
                    note: '',
                    tel: '',
                    address: '',
                    lat: '',
                    lng: '',
                    delivery_time: '',
                    sex: '',
                    pay_type: '',
                    time: ''
                },

                good: [],

                storeset: {
                    box_name: '',
                    is_cj: '',
                    cj_name: '',
                    ps_mode: ''
                }
            }
        };
    },
    onLoad: function (t) {
        app.globalData.setNavigationBarColor(this);
        console.log(t);
        var that = this;
        app.globalData.util.request({
            url: 'entry/wxapp/OrderInfo',
            cachetime: '0',
            data: {
                order_id: t.oid
            },
            success: function (t) {
                console.log(t.data);
                that.setData({
                    odinfo: t.data
                });
            }
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    methods: {
        maketel: function (t) {
            var a = t.currentTarget.dataset.tel;
            uni.makePhoneCall({
                phoneNumber: a
            });
        },

        copyText: function (t) {
            var a = t.currentTarget.dataset.text;
            uni.setClipboardData({
                data: a,
                success: function () {
                    uni.showToast({
                        title: '已复制'
                    });
                }
            });
        },

        location: function (t) {
            var a = t.currentTarget.dataset.lat;
            var e = t.currentTarget.dataset.lng;
            var o = t.currentTarget.dataset.address;
            console.log(a, e);
            uni.openLocation({
                latitude: parseFloat(a),
                longitude: parseFloat(e),
                address: o,
                name: '位置'
            });
        }
    }
};
</script>
<style>
@import './wmddxq.css';
</style>
